package net.myspring.middle.domain;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import net.myspring.common.domain.DataEntity;
import net.myspring.common.mybatis.provider.annotation.Entity;
import net.myspring.common.mybatis.provider.annotation.Table;
import net.myspring.common.utils.Collections3;

import java.util.List;
import java.util.Set;

/**
 * Created by liuj on 16/7/10.
 */
@Entity
@Table(name="sys_role")
public class Role extends DataEntity<Role> {
    private String name;
    private String code;
    private Set<Permission> permissionSet = Sets.newLinkedHashSet();
    private Set<Account> accountSet = Sets.newLinkedHashSet();

    private List<String> permissionIds = Lists.newArrayList();

    public List<String> getPermissionIds() {
        if (Collections3.isNotEmpty(permissionSet)) {
            permissionIds = Collections3.extractToList(permissionSet, "id");
        }
        return permissionIds;
    }

    public void setPermissionIds(List<String> permissionIds) {
        this.permissionIds = permissionIds;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Set<Permission> getPermissionSet() {
        return permissionSet;
    }

    public void setPermissionSet(Set<Permission> permissionSet) {
        this.permissionSet = permissionSet;
    }

    public Set<Account> getAccountSet() {
        return accountSet;
    }

    public void setAccountSet(Set<Account> accountSet) {
        this.accountSet = accountSet;
    }
}